package com.example.model;

import com.example.utils.JacksonUtil;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;

import java.io.IOException;
import java.util.List;

public class Machine_test {
    @JsonProperty("TestPoint")
    private  String testPoint;
    @JsonProperty("Value")
    private  String value;
    public String getTestPoint() {
        return testPoint;
    }
    public void setTestPoint(String testPoint) {
        this.testPoint = testPoint;
    }
    public String getValue() {
        return value;
    }
    public void setValue(String value) {
        this.value = value;
    }
//    public String getMachinedata() {
//
//        return testPoint;
//    }

    public static void main(String[] args) throws IOException {

        String dataStr = "[{\"TestPoint\": \"左长\",\"Value\": \"0.5646\"},{\"TestPoint\": \"平面度\",\"Value\": \"1.2298\"}]";
        List<Machine_test> list = JacksonUtil.json2Bean(dataStr, new TypeReference<List<Machine_test>>() {});
        String s = JacksonUtil.bean2Json(list);
        System.out.println("123456789"+s);
    }

    // canMerge方法，判断是否可与另一个Machine_test对象合并
    public boolean canMerge(Machine_test other) {
        // 这里假设当两个对象的测试编号相同且测试参数相同时，认为它们可以合并
        //return this.testId.equals(other.getTestId()) && this.testParameter.equals(other.getTestParameter());
        return true;
    }

    // merge方法，执行与另一个Machine_test对象的合并操作
    public void merge(Machine_test other) {
        // 这里可以根据具体业务需求来定义合并逻辑，比如对某些属性进行累加、更新等操作
        // 以下是一个简单示例，假设将另一个对象的测试参数追加到当前对象的测试参数后面
      //  this.testParameter += ", " + other.getTestParameter();
        this.testPoint += ", " + other.getTestPoint();
        this.value += ", " + other.getValue();
    }
}
